<%-- 
    Document   : index
    Created on : Apr 9, 2011, 2:33:33 PM
    Author     : Nick
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">


<html>
    <head>

        <title>Welcome</title>
        <script type="text/javascript"  src="usefulFunc.js"></script>
    </head>

    <body>
<!--        <a href="Test.html">Test</a>-->
        <%
                    String cookieName = "login";
                    Cookie cookies[] = request.getCookies();
                    Cookie myCookie = null;
                    if (cookies != null) {
                        for (int i = 0; i < cookies.length; i++) {
                            if (cookies[i].getName().equals(cookieName)) {
                                myCookie = cookies[i];
                                break;
                            }
                        }
                    }
                    if (myCookie == null) {
        %>
        <a href="Login.html">Login</a>
        <p style="position: absolute; top: 0; right: 10px;">Currently not log in</p>

        <%                            } else {
        %>
        <p style="position: absolute; top: 0; right: 10px;">Welcome: <%=myCookie.getValue()%></p>
        
        <a href="NewMessage.jsp">New message</a>

        <button type="button" onclick="rmCookie();">logout</button>
        <%
                    }
        %>
    </body>
</html>
